import SwiftUI

/*
 * 复选按钮示例
 */
class CheckBoxExample: FCUIView{
    /*
     * 鼠标按下方法
     * view:视图
     * mp:坐标
     * buttons:按钮
     * clicks:点击次数
     * delta:滚轮值
     */
    override func onMouseDown(view:FCView, mp:FCPoint, buttons:Int, clicks:Int, delta:Int)
    {
        super.onMouseDown(view: view, mp: mp, buttons: buttons, clicks: clicks, delta: delta)
    }
    
    /*
     * 鼠标移动方法
     * view:视图
     * mp:坐标
     * buttons:按钮
     * clicks:点击次数
     * delta:滚轮值
     */
    override func onMouseMove(view:FCView, mp:FCPoint, buttons:Int, clicks:Int, delta:Int)
    {
        super.onMouseMove(view: view, mp: mp, buttons: buttons, clicks: clicks, delta: delta)
    }
    
    /*
     * 鼠标抬起方法
     * view:视图
     * mp:坐标
     * buttons:按钮
     * clicks:点击次数
     * delta:滚轮值
     */
    override func onMouseUp(view:FCView, mp:FCPoint, buttons:Int, clicks:Int, delta:Int)
    {
        super.onMouseUp(view: view, mp: mp, buttons: buttons, clicks: clicks, delta: delta)
    }
    
    /*
     * 鼠标滚轮方法
     * view:视图
     * mp:坐标
     * buttons:按钮
     * clicks:点击次数
     * delta:滚轮值
     */
    override func onMouseWheel(view:FCView, mp:FCPoint, buttons:Int, clicks:Int, delta:Int)
    {
        super.onMouseWheel(view: view, mp: mp, buttons: buttons, clicks: clicks, delta: delta)
    }
    
    /*
     * 键盘按下方法
     * view:视图
     * value:键盘值
     */
    override func onKeyDown(view:FCView, value:Int)
    {
        super.onKeyDown(view: view, value: value)
    }
    
    /*
     * 键盘抬起方法
     * view:视图
     * value:键盘值
     */
    override func onKeyUp(view:FCView, value:Int)
    {
        super.onKeyUp(view: view, value: value)
    }

    /*
    * 点击方法
    * view:视图
    * firstTouch:是否第一次触摸
    * firstPoint:第一次触摸的坐标
    * secondTouch:是否第二次触摸
    * secondPoint:第二次触摸的坐标
    * clcks:点击次数
    */
    override func onClick(view:FCView, firstTouch:Bool, firstPoint:FCPoint, secondTouch:Bool, secondPoint:FCPoint, clicks:Int) {
        super.onClick(view:view, firstTouch:firstTouch, firstPoint:firstPoint, secondTouch:secondTouch, secondPoint:secondPoint, clicks: clicks)
    }

    /*
    * 重绘背景的实现方法
    * view:视图
    * paint:绘图对象
    * clipRect:裁剪区域
    */
    override func onPaint(view:FCView, paint:FCPaint, clipRect:FCRect) {
        super.onPaint(view:view, paint:paint, clipRect:clipRect)
    }

    /*
    * 重绘边框的实现方法
    * view:视图
    * paint:绘图对象
    * clipRect:裁剪区域
    */
    override func onPaintBorder(view:FCView, paint:FCPaint, clipRect:FCRect) {
        super.onPaintBorder(view:view, paint:paint, clipRect:clipRect)
    }
    
    /*
     * 初始化布局
     */
    override func onLoad(){
        let isInit = super.m_isInit;
        super.onLoad();
        if !isInit{
            m_paint.defaultUIStyle = "light"
            let width = Double(self.frame.size.width), height = Double(self.frame.size.height)
            renderFaceCat(name:"checkboxexample", paint: m_paint, size: FCSize(cx:width, cy:height))
            //获取第二页
            let tabPage = findViewByName(name:"TabPage2", views:m_paint.views);
            let checkBox = FCCheckBox()
            checkBox.location = FCPoint(x:100, y:100)
            checkBox.size = FCSize(cx:100, cy:20)
            addViewToParent(view:checkBox, parent:tabPage)
            checkBox.text = "选项"
        }
    }
}
